<?php

include_once dirname(__FILE__) . '/../system/settings.php';
if ($_POST) {
    $id = $_POST['id'];
    $name = $_POST['name'];
    
    if (!empty($id)) {
        if (!DiferenciaisControl::Update($name, $id)) {
            header("location: " . $_POST['redirect']);
            exit();
        }
    } else {
        if (!DiferenciaisControl::Insert($name)) {
            header("location: " . $_POST['redirect']);
            exit();
        }
    }
    header("location: " . $_POST['redirect']);
} else if ($_GET) {
    $id = $_GET['id'];
    if (!empty($id)) {
        DiferenciaisControl::Delete($id);
    }
    header("location: " . $_GET['redirect']);
}
?>
